package net.cardgame.orcalecard.utils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

import net.cardgame.orcalecard.bean.DeckBean;
import net.cardgame.orcalecard.bean.HistoryBean;

public class Sort {
	public static final Comparator<DeckBean> RELEASE_ORDER = new Comparator<DeckBean>() {
		public int compare(DeckBean d1, DeckBean d2) {
			return d1.releaseDate.compareTo(d2.releaseDate);
		}
	};
	static final Comparator<DeckBean> BUY_ORDER = new Comparator<DeckBean>() {
		public int compare(DeckBean d1, DeckBean d2) {
			return d1.buyDate.compareTo(d2.buyDate);
		}
	};
	static final Comparator<DeckBean> USED_ORDER = new Comparator<DeckBean>() {
		public int compare(DeckBean d1, DeckBean d2) {
			return d1.lastUsedDate.compareTo(d2.lastUsedDate);
		}
	};
	static final Comparator<HistoryBean> DATE_ORDER = new Comparator<HistoryBean>() {
		public int compare(HistoryBean d1, HistoryBean d2) {
			return d1.datetime.compareTo(d2.datetime);
		}
	};

	public static ArrayList<HistoryBean> sortHistoryByDate(
			ArrayList<HistoryBean> list) {
		Collections.sort(list, DATE_ORDER);
		Collections.reverse(list);
		return list;
	}

	public static ArrayList<DeckBean> sortByRelease(ArrayList<DeckBean> list) {
		Collections.sort(list, RELEASE_ORDER);
		Collections.reverse(list);
		return list;
	}

	public static ArrayList<DeckBean> sortByBuy(ArrayList<DeckBean> list) {
		Collections.sort(list, BUY_ORDER);
		Collections.reverse(list);
		return list;
	}

	public static ArrayList<DeckBean> sortByLastUsed(ArrayList<DeckBean> list) {
		Collections.sort(list, USED_ORDER);
		Collections.reverse(list);
		return list;
	}

}
